//
//  LoginTipView.swift
//  Box
//
//  Created by mn on 2025/3/31.
//

import UIKit
import SnapKit

class LoginTipView: UIView {
    
    private let leftImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage(named: "login_left")
        imageView.contentMode = .scaleAspectFit
        return imageView
    }()
    
    private let rightImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage(named: "login_right")
        imageView.contentMode = .scaleAspectFit
        return imageView
    }()
    
    let textLabel: UILabel = {
        let label = UILabel()
        label.textColor = .fromHex("#B3F832")
        label.font = .boldSystemFont(ofSize: 28)
        label.textAlignment = .center
        return label
    }()
    
    let tipLabel: UILabel = {
        let label = UILabel()
        label.text = "未注册手机验证后将自动登录"
        label.textColor = .fromHex("#717171")
        label.font = .systemFont(ofSize: 14)
        label.textAlignment = .center
        return label
    }()
    
    private let stackView: UIStackView = {
        let stackView = UIStackView()
        stackView.axis = .horizontal
        stackView.alignment = .center
        stackView.distribution = .equalSpacing
        stackView.spacing = 10
        return stackView
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupView()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setupView()
    }
    
    private func setupView() {
        addSubview(stackView)
        stackView.addArrangedSubview(leftImageView)
        stackView.addArrangedSubview(textLabel)
        stackView.addArrangedSubview(rightImageView)

        addSubview(tipLabel)
        
        stackView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.leading.greaterThanOrEqualToSuperview().offset(10)
            make.trailing.lessThanOrEqualToSuperview().offset(-10)
        }
        
        tipLabel.snp.makeConstraints { make in
            make.top.equalTo(stackView.snp.bottom).offset(5)
            make.centerX.equalToSuperview()
            make.bottom.lessThanOrEqualToSuperview()
        }
    }
}
